package org.rapan;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.rapan.EJB.ConsultantInt;
import org.rapan.jpa.Consultant;

import com.vaadin.Application;
import com.vaadin.terminal.ExternalResource;

@SuppressWarnings("serial")
public class RapanApplication extends Application {

	@Override
	public void init() {
		setTheme("ConsultTheme");
		try {
			InitialContext context = new InitialContext();
			ConsultantInt conInt = (ConsultantInt) context
					.lookup("Consult/ConsultantBean/local");
			conInt.checkAndCreateAdmin();

		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		setMainWindow(new LoginWin());

	}

	public void Login(Consultant c) {
		getMainWindow().open(new ExternalResource(getURL()));
		setMainWindow(new MainWin(c));
	}

}
